home *** CD-ROM | disk | FTP | other *** search
- Path: airdmhor.gen.nz!not-for-mail
- From: gumboot@airdmhor.gen.nz (Simon Hosie)
- Newsgroups: comp.lang.c
- Subject: Re: Help on random numbers
- Date: 13 Feb 1996 05:09:01 +1300
- Organization: Airdmhor
- Message-ID: <4fnomt$d5e@airdmhor.gen.nz>
- References: <4f7193$4bi@jaring.my>
- NNTP-Posting-Host: airdmhor.gen.nz
- X-Newsreader: TIN [version 1.2 PL2]
-
- Tan Shu Wei:
- > Hi everyone. I need some help on generating random numbers.
-
- > I'm using Turbo C++ under DOS, and I would like to know how
- > to generate random numbers. I've tried using random() and
- > randomize() but I keep getting the same random number. Can
- > help me, or even give me a short explanation on how randomize()
- > works?
-
- toy need to call srand() first. With TC I'd suggest..
-
- srand(*(unsigned int far *)0x0040006cL);
-
- because that, as a seed, is incremented 18 and a bit times faster than
- time(). Otherwise use the time function or something..
-
- srand((unsigned int)time(NULL));
-
- If you want an explaination of randomize() then type 'randomize' in the
- IDE, cursor left once, and hit Ctrl-F1.
-